package com.jiaxz.cloud.cloud.controller;

import com.jiaxz.cloud.cloud.entity.User;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class MovieController {
    @Autowired
    private RestTemplate restTemplate;
    @HystrixCommand(fallbackMethod="findByIdFallBack")
    @GetMapping("/movie/findById/{id}")
    public User findById(@PathVariable("id")Long id){
        return this.restTemplate.getForObject("http://MICROSERVICE-SIMPLE-PROVICER-USER/user/findById/"+id,User.class);
    }
    public User findByIdFallBack(Long id) {
    	User user = new User();
    	user.setId(0L);
        return user;
    }
}
